import 'dart:convert' show json;

class CommonWebsiteModel {
  int? errorCode;
  String? errorMsg;
  List<CommonWebsiteData>? data;

  CommonWebsiteModel({this.errorCode, this.errorMsg, this.data});

  factory CommonWebsiteModel.fromParams({int? errorCode, String? errorMsg, List<CommonWebsiteData>? data}) {
    return CommonWebsiteModel(errorCode: errorCode, errorMsg: errorMsg, data: data);
  }

  factory CommonWebsiteModel.fromJson(dynamic jsonStr) {

    final Map<String, dynamic> jsonRes = jsonStr is String ? json.decode(jsonStr) : jsonStr;
    return CommonWebsiteModel(
      errorCode: jsonRes['errorCode'],
      errorMsg: jsonRes['errorMsg'],
      data: jsonRes['data'] != null
          ? List<CommonWebsiteData>.from(
        jsonRes['data'].map((dataItem) => CommonWebsiteData.fromJson(dataItem)),
      )
          : [],
    );
  }

  @override
  String toString() {
    return '{"errorCode": $errorCode, "errorMsg": ${errorMsg != null ? json.encode(errorMsg) : 'null'}, "data": $data}';
  }
}

class CommonWebsiteData {
  int? id;
  int? order;
  int? visible;
  String? icon;
  String? link;
  String? name;

  CommonWebsiteData({this.id, this.order, this.visible, this.icon, this.link, this.name});

  factory CommonWebsiteData.fromParams({int? id, int? order, int? visible, String? icon, String? link, String? name}) {
    return CommonWebsiteData(id: id, order: order, visible: visible, icon: icon, link: link, name: name);
  }

  factory CommonWebsiteData.fromJson(Map<String, dynamic> jsonRes) {
    return CommonWebsiteData(
      id: jsonRes['id'],
      order: jsonRes['order'],
      visible: jsonRes['visible'],
      icon: jsonRes['icon'],
      link: jsonRes['link'],
      name: jsonRes['name'],
    );
  }

  @override
  String toString() {
    return '{"id": $id, "order": $order, "visible": $visible, "icon": ${icon != null ? json.encode(icon) : 'null'}, "link": ${link != null ? json.encode(link) : 'null'}, "name": ${name != null ? json.encode(name) : 'null'}}';
  }
}
